home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_nub_randomambient.cog < prev    next >
Text File  |  1999-11-15  |  2KB  |  107 lines

  1. # Jones 3D Cog Script
  2. #
  3. # nub_RandomAmbient.cog
  4. #
  5. # [SXC] [TL] on bass...
  6. #
  7. # (C) 1999 LucasArts Entertainment Co. All Rights Reserved
  8. #
  9. # =======================================================================================
  10. symbols
  11.  
  12. message    startup
  13. message    timer
  14. message    entered
  15.  
  16. sector    soundOnSector
  17. sector    soundOffSector
  18.  
  19. sound    wav0
  20. sound    wav1
  21. sound    wav2
  22. sound    wav3
  23. sound    wav4
  24.  
  25. int        numsounds
  26. int        b_IsPlaying            local
  27. int        TIMERID_AMB=1        local
  28.  
  29. flex    min_interval
  30. flex    range_interval
  31. flex    min_volume
  32. flex    range_volume
  33.  
  34. int        temp                local
  35. int        nubSound            local
  36. int        startcog=0                        # set as 1 for cog to run at startup
  37.  
  38. end
  39.  
  40. # ========================================================================================
  41. code
  42.  
  43. # ........................................................................................
  44. startup:
  45.  
  46.     b_IsPlaying = 0;
  47.  
  48.     if (startcog != 1) return;
  49.     SetTimerEx(min_interval+(rand()*range_interval), TIMERID_AMB, 0, 0);
  50.  
  51.     return;
  52.  
  53.  
  54. # ........................................................................................
  55. timer:
  56.  
  57.     # Dont play sound if already doing so, but try again later
  58.     if ( b_IsPlaying == 1 )
  59.     {
  60.         SetTimerEx(min_interval+(rand()*range_interval), TIMERID_AMB, 0, 0);
  61.         return;
  62.     }
  63.  
  64.     temp = rand()*numsounds;
  65.     nubSound = playsoundlocal(wav0[temp], 1, ((rand()*2)-1.0), 0, 0);        # volume was (min_volume+(rand()*range_volume))
  66.  
  67.     if (nubSound != -1)
  68.     {
  69.         b_IsPlaying = 1;
  70.  
  71.         ChangeSoundPitch(nubSound, (Rand() + 0.25), 0.01);                    # was ChangeSoundPitch(nubSound, (Rand() + 0.1) * RandBetween(1, 2), 0.01);
  72.         WaitForSound(nubSound);
  73.  
  74.         b_IsPlaying = 0;
  75.     }
  76.  
  77.     SetTimerEx(min_interval+(rand()*range_interval), TIMERID_AMB, 0, 0);
  78.  
  79.     return;
  80.  
  81.  
  82. # ........................................................................................
  83. entered:
  84.  
  85.     if (GetSenderRef() == soundOnSector)
  86.     {
  87.         SetTimerEx(min_interval + (rand()*range_interval), TIMERID_AMB, 0, 0);
  88.         return;
  89.     }
  90.  
  91.     if (GetSenderRef() == soundOffSector)
  92.     {
  93.         KillTimerEx(TIMERID_AMB);
  94.  
  95.         if ( b_IsPlaying == 1 )
  96.         {
  97.             Reset();
  98.             b_IsPlaying = 0;
  99.             StopSound(nubSound, 0.9);
  100.         }
  101.     }
  102.  
  103.     return;
  104.  
  105. # ........................................................................................
  106. end
  107.